<?php

class Core_Helper_Global_Helper {

    public function getAreas($isFrontend = TRUE, $isBackend = TRUE) {
        $areas = App::getModel('global/collection_area')->asc('is_backend');
        if ($isFrontend && $isBackend) {
            
        } elseif ($isFrontend) {
            $areas->eq('is_backend', 0);
        } elseif ($isBackend) {
            $areas->eq('is_backend', 1);
        }
        return $areas->load();
    }

    public function loadModule($name) {
        return App::getModel('global/module')->loadByName($name);
    }

    public function getModules($areaId) {
        return App::getModel('global/collection_module')->joinWebsiteArea()->filterByArea($areaId)->load();
    }

    public function getTemplates($areaId) {
        return App::getModel('global/collection_template')->filterByArea($areaId)->load();
    }

    public function getMenus($areaId) {
        return App::getModel('global/collection_menu')->joinArea()->filterByArea($areaId)->load();
    }

    public function registerKeywords(array $keywords, $targetId, $type) {
        App::getModel('global/keyword')->registerKeywords($keywords, $targetId, $type);
    }

    public function unregisterKeywords(array $keywords, $targetId, $type) {
        App::getModel('global/keyword')->unregisterKeywords($keywords, $targetId, $type);
    }

    public function updateKeywords(array $oldKeywords, array $newKeywords, $targetId, $type) {
        App::getModel('global/keyword')->updateKeywords($oldKeywords, $newKeywords, $targetId, $type);
    }

}